package com.stations.controller;

import com.github.pagehelper.PageInfo;
import com.stations.common.constant.ControllerConstant;
import com.stations.common.web.base.BaseController;
import com.stations.common.web.domain.request.PageDomain;
import com.stations.common.web.domain.response.Result;
import com.stations.common.web.domain.response.module.ResultTable;
import com.stations.domain.ExceptionLog;
import com.stations.domain.TTransmitterLog;
import com.stations.service.TrasmiterLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Describe: 发射机日志控制器
 * Author: Ljy
 * CreateTime: 2019/10/23
 */
@RestController
@Api(tags = {"发射机日志管理"})
@RequestMapping(ControllerConstant.API_SYSTEM_PREFIX + "transmitterlog")
public class TransmiterLogController extends BaseController {

    /**
     * Describe: 基础路径
     */
    private static String MODULE_PATH = "system/transmitterlog/";

    @Resource
    private TrasmiterLogService trasmiterLogService;

    /**
     * Describe: 获取发射机日志列表
     * Param ModelAndView
     * Return 获取发射机日志列表
     */
    @GetMapping(value = "/getLogs")
    @ApiOperation(value = "获取发射机日志列表")
    @PreAuthorize("hasPermission('/system/transmitterlog/getLogs','sys:transmitterlog:getLogs')")
    public Result getLogs(HttpServletRequest request) {
        List<ExceptionLog> lisExceptionLog= trasmiterLogService.getLogs();
        return Result.success(lisExceptionLog);
    }

    /**
     * 分页查询发射机日志列表
     */
    @ResponseBody
    @GetMapping("/data")
    @PreAuthorize("hasPermission('/system/transmitterlog/data','sys:transmitterlog:data')")
    public ResultTable list(@ModelAttribute TTransmitterLog tTransmitterLog, PageDomain pageDomain) {
        PageInfo<TTransmitterLog> pageInfo = trasmiterLogService.selectTTransmitterLogPage(tTransmitterLog, pageDomain);
        return pageTable(pageInfo.getList(), pageInfo.getTotal());
    }
}
